﻿using ConfExpert.Forms.Base;
using ConfExpert.Utility;
using DevTeam;
using System;
using System.Data;
using System.Windows.Forms;

namespace ConfExpert.Forms.Depo.Aksesuar
{
    public partial class Sevkiyatci : XForm
    {
        BindingSource bs;
        public Sevkiyatci()
        {
            InitializeComponent();
        }

        private void Sevkiyatci_Load(object sender, EventArgs e)
        {
            txtInfo.Caption = "Sevkiyatçılar";
            TAM.SevkiyatciTableAdapter = new ConfExpert.Datasets.MyDataTableAdapters.SevkiyatciTableAdapter();
            TAM.SevkiyatciTableAdapter.Fill(ds.Sevkiyatci);
            bs = new BindingSource(ds, "Sevkiyatci");

            AddBsToList(bs);
            InitGridView(gvOverview, bs);
            gvOverview.OptionsView.NewItemRowPosition = DevExpress.XtraGrid.Views.Grid.NewItemRowPosition.Bottom;

            bs.CurrentChanged += new EventHandler(bs_CurrentChanged);
            btnKaydet.ItemClick += btnKaydet_ItemClick;
            gvOverview.BestFitColumns();
        }

        void bs_CurrentChanged(object sender, EventArgs e)
        {
            txtInfo.Caption = ((DataRowView)bs.Current).Row["Name"].ToString();
        }

        void btnKaydet_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            gvOverview.EndEditing();
            Save();
            AppSession.MainForm.RefreshData();
        }
    }
}